home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / showfont.pro < prev    next >
Text File  |  1997-07-08  |  2KB  |  107 lines

  1. ; $Id: showfont.pro,v 1.5 1997/01/15 03:11:50 ali Exp $
  2. ;
  3. ; Copyright (c) 1992-1997, Research Systems, Inc.  All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5.  
  6. PRO SHOWFONT, FONT, NAME, ENCAPSULATED = encapsulated
  7. ;+
  8. ; NAME:
  9. ;    SHOWFONT
  10. ;
  11. ; PURPOSE:
  12. ;    This procedure displays a vector-drawn font on the current
  13. ;    graphics device.
  14. ;
  15. ; CATEGORY:
  16. ;    Fonts.
  17. ;
  18. ; CALLING SEQUENCE:
  19. ;    SHOWFONT, Font, Name
  20. ;
  21. ; INPUTS:
  22. ;    Font:     The index number of the font (may range from 3 to 29).
  23. ;    Name:     Title text to appear at top of display.
  24. ;
  25. ; KEYWORD PARAMETERS:
  26. ;    ENCAPSULATED:    If this keyword is set, and if the current graphics
  27. ;            device is "PS", makes encapsulated PostScript output.
  28. ;
  29. ; OUTPUTS:
  30. ;    No explicit outputs.
  31. ;
  32. ; SIDE EFFECTS:
  33. ;    A display is made.
  34. ;
  35. ; RESTRICTIONS:
  36. ;    Not very flexible.
  37. ;
  38. ; PROCEDURE:
  39. ;    Straightforward.
  40. ;
  41. ; EXAMPLE:
  42. ;    To create a display of Font 3 for PostScript:
  43. ;        SET_PLOT, 'PS'
  44. ;        SHOWFONT, 3, "Simplex Roman"
  45. ;
  46. ; MODIFICATION HISTORY:
  47. ;     Written by:
  48. ;    DMS, Nov, 1992
  49. ;    WSO, 1/95, Updated for new directory structure
  50. ;-
  51.  
  52. if !d.name eq 'PS' then begin
  53.     device, encap=KEYWORD_SET(encapsulated)    ;Set encapsulated PS attribute
  54. endif
  55.  
  56. erase
  57. sesc = '!'+strtrim(font,2)    ; Font selecting string
  58.  
  59. openr, unit, /GET_LUN, filepath('hersh1.chr', subdir=['resource', 'fonts'])  ;Peek into font file
  60. hdr = lonarr(2,40)
  61. readu, unit, hdr
  62.         ;Determine # of chars in font:
  63. if hdr[1,font] lt 0 then nchars = 224 else nchars = 96  ;8 or 7 bits?
  64. FREE_LUN, unit
  65.  
  66. ;    Title line:
  67. xyouts,0.5,.95,'!3Font '+strtrim(font,2)+', '+name,siz=2.5,$
  68.     alig=0.5,/norm
  69.  
  70. nrows = nchars / 16
  71. y0 = 0.87        ;Top line
  72. y1 = 0.03        ;Bottom
  73. dy = (y1-y0) / nrows
  74. x0 = 0.03        ;Left
  75. x1 = .97        ;Right
  76. dx = (x1-x0) / 17
  77.  
  78. for ix=0,16 do begin    ;Each column
  79.     x = x0 + ix * dx
  80.     y = y0 + 0.01
  81.     xx = x + dx/2
  82.     if ix eq 0 then s = '!3Octal' else $   ;Column header
  83.         s = string((ix-1) and 15, format='(O2.2)')
  84.     xyouts, xx, y, s, /NORM, ALIGN=0.5
  85.     plots, [x,x],[y0,y1], /norm
  86.     endfor
  87.  
  88. plots, [x1, x1], [y0, y1], /NORM 
  89. plots, [x0, x1], [y0, y0], /NORM
  90.  
  91. for iy=0, nrows-1 do begin
  92.     y = y0 + (iy+1) * dy
  93.     plots, [x0, x1], [y, y], /NORM
  94.     xyouts, x0+dx/2, y-dy/5, /NORM, ALIGN=0.5, $
  95.         string((iy*16+32)/8, format="('!3',O2.2,'x')")
  96.     for ix=0,15 do begin        ;Each character
  97.         X = (ix+1) * dx + x0
  98.         k = iy*16 + ix + 32
  99.         s = string(byte(k))
  100.         if s eq '!' then s = '!!'
  101.         xyouts,x+.0225,y+.005,sesc+s,size=2.0,/norm,font=-1
  102.         endfor
  103.     ENDFOR
  104. RETURN
  105. END
  106.  
  107.